<%@ page contentType="text/html; charset=UTF-8" language="java" import="java.sql.*" errorPage="" %>
<%
String userid=(String)session.getAttribute("userid");

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>无标题文档</title>
</head>
 <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title>My App</title>
    <!-- Path to Framework7 Library CSS-->
    <link rel="stylesheet" href="/css/framework7.ios.min.css">
    <!-- Path to your custom app styles-->
    <link rel="stylesheet" href="css/my-app.css">
<%--   <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">--%>
<script src="js/jquery-1.4.2.min.js" language="JavaScript"></script>
<%--<style>
	
input{
                border: 1px solid #ccc;
                padding: 7px 0px;
                border-radius: 3px;
                padding-left:5px;
				font-size:20px;
			
                -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
                box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
                -webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
                -o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
                transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s
            }
        select{
                border: 1px solid #ccc;
                padding: 7px 0px;
                border-radius: 3px;
                padding-left:5px;
				font-size:33px;
			
                -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
                box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
                -webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
                -o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
                transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s
            }
		input::-webkit-input-placeholder{font-size:38px; height:43px } 

            input:focus{
                    border-color: #66afe9;
                    outline: 0;
                    -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);
                    box-shadow: inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)
            }


</style>--%>

 <div style="border:1px solid #f0f0f0; height:32px; width:100%">
         <div style="width:10%; float:left; margin-top:10px">  <img   onclick="backs()" src="image/back.png"    height="20px;" /></div>
	     <div  onclick="backss()" id="sqname" style="width:90%;  text-align:center ;float:left; font-size:20px;margin-top:2px">签约 </div>	
  </div>
   
	
  <%-- <div  id="doctorname" style="height:15px;  line-height:15px; font-size:15px; margin-top:-25px;"></div>--%>
	 <form  id="form" name="form" method="post" action="contractxml.jsp">
	          <input   type="hidden"  name="opt" value="sign" />
		     <input   type="hidden"  name="doctor_id" value="<%=request.getParameter("doctor_id")%>" />
			 <input   name="sqfwzx_id"    type="hidden"   value="<%=request.getParameter("sqfwzx_id")%>" />
			 <input   type="hidden"  id="tel" name="tel"   value="<%=request.getParameter("tel")%>" />
              <div class="list-block "  >
                <ul>
				
				  <li style="margin-left:0px;">
                    <div class="item-content"  >
                      <div class="item-inner" > 
                        <div class="item-title label">医生</div>
                        <div class="item-input">
                          <input type="text"   id="doctorname"  readonly   placeholder="Your name">
                        </div>
                      </div>
                    </div>
                  </li>
                  <li style="margin-left:0px;">
                    <div class="item-content"  >
                      <div class="item-inner" > 
                        <div class="item-title label">姓名</div>
                        <div class="item-input">
                          <input type="text"  name="name"  id="name" maxlength="11"  placeholder="Your name">
                        </div>
                      </div>
                    </div>
                  </li>
                  <li>
                    <div class="item-content">
                   
                      <div class="item-inner"> 
                        <div class="item-title label">身份证号码</div>
                        <div class="item-input">
                          <input type="email"  name="card"   id="card" maxlength="18"   placeholder="E-mail">
                        </div>
                      </div>
                    </div>
                  </li>
                  <li>
				     <div class="item-content">
             
                      <div class="item-inner"> 
                        <div class="item-title label">街道</div>
                        <div class="item-input">
                          <select  id="addresscode" name="addresscode">
                            <option > 请选择街道</option>
                         
                          </select>
                        </div>
                      </div>
                    </div>
                  </li>
                 
                  <li>
                    <div class="item-content">
                   
                      <div class="item-inner"> 
                        <div class="item-title label">详细地址</div>
                        <div class="item-input">
                          <input type="email"    name="address"  id="address" maxlength="66"/>
                        </div>
                      </div>
                    </div>
                  </li>
                  <li>
                 
             
              
                 
                   
                </ul>
              </div>
			 </form> 
		 <form  id="form" name="form" method="post" action="contractxml.jsp">
		   <%--  <input   type="hidden"  name="opt" value="sign" />
		     <input   type="hidden"  name="doctor_id" value="<%=request.getParameter("doctor_id")%>" />
			 <input   name="sqfwzx_id"    type="hidden"   value="<%=request.getParameter("sqfwzx_id")%>" />
			 <input   type="hidden"  id="tel" name="tel"   value="<%=request.getParameter("tel")%>" />
	   <input  style="width:100%;height:30px;"   name="name"  id="name" maxlength="11"    placeholder="姓名"/>
		     <input  style="width:100%;height:30px;"   name="card"   id="card" maxlength="18"   placeholder="身份证号码"/>
		  <select   style="width:100%;"  id="addresscode" name="addresscode">
		     <option value=""> 请选择街道</option>
		  </select>
			 <input  style="width:100%;height:30px;"   name="address"  id="address" maxlength="66"   placeholder="详细地址"/>
			</form>--%>
			<div style="margin-top:2px;">
			 <button    id="logon" type="button" style="height:40px; font-size:22px; width:100%"   class="item-input" onClick="emit()">签约</button>
			 
			 </div>
<body>
</body>
</html>
<script>


var id='<%=request.getParameter("doctor_id")%>';
window.onload=function(){ 

 $.ajax( {    
    url:'/QueyServlet',
    type:'post',    
    cache:false,  
	data:{op:'sqdoctor',doctor_id:id},  
    dataType:'json',    
    success:function(msg) {
	if(msg.result=="ok"){
	    var data=msg.data;
	    if(data.length==1){
	   	   $("#doctorname").val(data[0].doctor_name);
	    }
		}
	},
	  error : function() 
	 {     
         alert("异常！");    
    }    
});
  
 $.ajax( {    
    url:'/QueyServlet',
    type:'get',    
    cache:false,  
	data:{op:'appuser',tel:$('#tel').val(),id:'<%=userid%>'},  
    dataType:'json',    
    success:function(msg) { 	
	if(msg.result=="ok"){
	var data=msg.data;
	   if(data.length==1){
	   $("#name").val(data[0].name);
	   $("#card").val(data[0].card);
	   $("#address").val(data[0].address);
	   }
	   }
    $.ajax( {    
       url:'/QueyServlet',
         type:'get',    
         cache:false,  
	    data:{op:'qydm'},  
        dataType:'json',    
        success:function(msg) { 
		if(msg.result=="ok"){
	       var data=msg.data;
	      for(var i=0;i<data.length;i++){
             $("#addresscode").append("<option value='"+data[i].addresscode+"'>"+data[i].unitname+"</option>");
	       }
	      }
		} 
       });
	},
	  error : function() 
	 {     
         alert("异常！");    
    }    
});
}
function  emit(){
     var msg = "确认提交签约申请吗！"; 
      if (confirm(msg)){
	      $.ajax({
          type: "POST",  
          url:"/UserServlet", //你的请求程序页面随便啦
		 data:decodeURIComponent($('#form').serialize(),true),// 你的formid   
         async:false,//同步：意思是当有返回值以后才会进行后面的js程序。
	   dataType:'json', 
         success:function(msg){
		 	 if(msg.result=="error"){
			   alert("请登录");
			 
			 }else 
		 
		 if(msg.result=="sign")
		     alert("您已经签约了");
                    else		  
	               parent.location="contractok.jsp?contract_id="+msg.contraract_id+"&doctor_id="+msg.doctor_id+""; 
    
         } 
	     });
	  }

   }

</script>